package club.xyes.zkh.ecommerce.commons.entity;

import club.xyes.zkh.ecommerce.commons.context.ApplicationConstants;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Table;
import java.util.Date;

/**
 * Create by 郭文梁 2019/4/18 0018 13:16
 * Coupon
 * 优惠券实体类
 *
 * @author 郭文梁
 * @data 2019/4/18 0018
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Table(name = "t_coupon")
public class Coupon extends BaseEntity {
    /**
     * 折扣方式：代金券
     */
    public static final int DISCOUNT_CASH_COUPON = 0x01;
    /**
     * 折扣方式：打折券
     */
    public static final int DISCOUNT_DISCOUNT_COUPON = 0x02;
    /**
     * 商铺ID
     */
    @Column(name = "shop_id", length = 10, nullable = false)
    private Integer shopId;
    /**
     * 关联的商铺对象
     */
    private Shop shop;
    /**
     * 优惠券名称
     */
    @Column(name = "name", nullable = false)
    private String name;
    /**
     * 折扣方式
     */
    @Column(name = "discount_way", length = 2, nullable = false)
    private Integer discountWay;
    /**
     * 有效时间：开始
     */
    @Column(name = "start_time", nullable = false)
    @JsonFormat(pattern = ApplicationConstants.DATE_TIME_FORMAT)
    private Date startTime;
    /**
     * 有效时间：结束
     */
    @Column(name = "end_time", nullable = false)
    @JsonFormat(pattern = ApplicationConstants.DATE_TIME_FORMAT)
    private Date endTime;
    /**
     * 最低消费金额
     */
    @Column(name = "min_amount", nullable = false, length = 100)
    private String minAmount;
    /**
     * 使用星期时间区间：开始
     */
    @Column(name = "week_range_start", nullable = false)
    private Integer weekRangeStart;
    /**
     * 使用星期时间区间：结束
     */
    @Column(name = "week_range_end", nullable = false)
    private Integer weekRangeEnd;
    /**
     * 使用时间区间：开始
     */
    @Column(name = "time_range_start", nullable = false)
    @JsonFormat(pattern = ApplicationConstants.TIME_FORMAT)
    private Date timeRangeStart;
    /**
     * 使用时间区间：结束
     */
    @Column(name = "time_range_end", nullable = false)
    @JsonFormat(pattern = ApplicationConstants.TIME_FORMAT)
    private Date timeRangeEnd;
    /**
     * 优惠金额
     */
    @Column(name = "amount", length = 100)
    private String amount;
    /**
     * 打折率 0.97 = 97折
     */
    @Column(name = "discount_rate", length = 100)
    private String discountRate;
    /**
     * 是否和会有优惠冲突（互斥）
     */
    @Column(name = "mutual_exclusion_with_membership_discount", nullable = false)
    private Boolean mutualExclusionWithMembershipDiscount;
    /**
     * 图片
     */
    @Column(name = "image")
    private String image;
    /**
     * 描述
     */
    @Column(name = "description")
    private String description;
    /**
     * 是否自动发放
     */
    @Column(name = "auto_grant")
    private Boolean autoGrant;
    /**
     * 自动发放最低消费金额
     */
    @Column(name = "grant_condition_amount", length = 10)
    private Integer grantConditionAmount;
}
